<?php

/**
 * @author chenshubo
 * 商品分类清单查询
 */
namespace App\Service\OrderService\OrderInterfaceService;

use App\Service\Code\Normal;
use App\Service\BaseService;
use App\Model\CommodityModel\Classifyinfo;

class QueryGoodsCategoryList extends BaseService
{    
    /**
     * 商品分类清单查询
     */
    public function index( $param = [] ) 
    {
        $bid            = $param['binfo']['bid'];
        $requestData    = $param['requestData'];
        $cacheKey       = md5(http_build_query($requestData));
        $cacheKey       = "WEB_QUERYGOODSCATEGORYLIST_{$bid}_".$cacheKey;
        $redis          = $this->getRedisObj();
        $redis->select(self::rdb_num);
        $lists = $redis->get($cacheKey);
        if( !empty($lists) ) {
            $lists = json_decode($lists,true);
            return Normal::returnCode(Normal::SUC,"获取成功",[
                'classList' => $lists
            ]);
        }
        
        $lists = Classifyinfo::instance()->getClassLists();
        
        //更新查询结果到缓存
        $redis->set($cacheKey,json_encode($lists),self::CACHE_TIME);
        
        return Normal::returnCode(Normal::SUC,"获取成功",[
            'classList' => $lists
        ]);
    }
}